<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>17.自定义可迭代的对象</title>
</head>
<body>
<script>
  let banji = {
    name: '终极一班',
    students:['a','b','c','d'],
    [Symbol.iterator]: function () {
      let index = -1
      return {

        next: ()=> {
          index++
          if (index<this.students.length){
            return {value:this.students[index],done:false}
          }else {
            return {value: undefined,done: true}
          }
        }
      }
    }
  }

  let iterator = banji[Symbol.iterator]()
  console.log(iterator.next())
  console.log(iterator.next())
  console.log(iterator.next())
  console.log(iterator.next())
  console.log(iterator.next())
  console.log(iterator.next())
</script>
</body>
</html>